package com.urms.controller.userRole;

import com.urms.entity.UserRole;
import com.urms.service.UserRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/userRole")
public class UserRoleController {
    @Autowired
    private UserRoleService userRoleService;

    @PostMapping("/insertUserRole")
    public Integer insertUserRole(String userLoginName,Integer userId, Integer[] roleIds){
        return userRoleService.insertUserRole(userLoginName,userId,roleIds);
    }

    @GetMapping("/selectAllRoleId")
    public List<UserRole> selectRoleByUserId(Integer userId){
        return userRoleService.selectRoleByUserId(userId);
    }

    @GetMapping("/selectRoleNameByUId")
    public List<String> selectRoleNameByUId(Integer userId){
        return userRoleService.selectRoleNameByUId(userId);
    }
}
